self.historySaveCmds = historySaveCmds
self.debugMe = False
self.limit = None
+ self.delay = 2
consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
- if verbose:
- print "Console executing: " + str(consoleCmd)
+ start = time.time()
+
+ while (time.time() - start) < self.TIMEOUT:
+ if verbose:
+ print "Console executing: %s" % str(consoleCmd)
- pid, fd = pty.fork()
+ pid, fd = pty.fork()
- if pid == 0:
- os.execvp("/usr/sbin/xm", consoleCmd[1:])
+ if pid == 0:
+ os.execvp("/usr/sbin/xm", consoleCmd[1:])
- self.consolePid = pid
- self.consoleFd = fd
+ self.consolePid = pid
+ self.consoleFd = fd
- tty.setraw(self.consoleFd, termios.TCSANOW)
+ tty.setraw(self.consoleFd, termios.TCSANOW)
- bytes = self.__chewall(self.consoleFd)
- if bytes < 0:
- raise ConsoleError("Console didn't respond")
+ bytes = self.__chewall(self.consoleFd)
+
+ if bytes > 0:
+ return
+ if verbose:
+ print "Console didn't attach, waiting %i sec..." % self.delay
+ time.sleep(self.delay)
+
+ raise ConsoleError("Console didn't respond after %i secs" % self.TIMEOUT)
+
def __addToHistory(self, line):
self.historyBuffer.append(line)
self.historyLines += 1